package com.example.version.controll.util;

import com.example.version.controll.VersionControllApplication;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.springframework.boot.system.ApplicationHome;

import java.io.File;

public class PathManagerUtil {
    public static String basePath = "";
    public static String configPath = "";
    public static String buildCachePath = "";
    public static String gradleSortPath = "";
    public static String batPath = "";
    public static String gitDataPath = "";

    static {
        // 初始化，获取jar包路径，读取config中的配置
        ApplicationHome ah = new ApplicationHome(VersionControllApplication.class);
        try {
            basePath = ah.getSource().getParentFile().toString();
        } catch (Exception e) {
            basePath = ah.getDir().toString();
        }
        batPath += basePath + "\\bat\\";
        File file = new File(batPath);
        if (!file.exists()) {
            file.mkdir();
        }
        gitDataPath += basePath + "\\gitData\\";
        file = new File(gitDataPath);
        if (!file.exists()) {
            file.mkdir();
        }
        configPath += basePath + "/config.txt";
    }
}
